/*
 * Powered By XY
 * Since 2020
 */

package com.xy.biz.fd.manager.impl;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xy.biz.fd.domain.bo.DocumentAttachmentBO;
import com.xy.biz.fd.domain.query.DocumentAttachmentQuery;
import com.xy.biz.fd.domain.converter.DocumentAttachmentConverter;
import com.xy.biz.fd.manager.DocumentAttachmentManager;
import com.xy.biz.fd.dao.DocumentAttachmentDao;

/**
 *
 *
 * @author wcs
 * @date 2021-2-19
 */
@Service
public class DocumentAttachmentManagerImpl implements DocumentAttachmentManager {

	@Autowired
	private DocumentAttachmentDao documentAttachmentDao;

	@Override
	public int saveDocumentAttachment(DocumentAttachmentBO documentAttachmentBO) {
		return documentAttachmentDao.saveDocumentAttachment(DocumentAttachmentConverter.toPO(documentAttachmentBO));
	}

	@Override
	public int saveAllDocumentAttachment(Collection<DocumentAttachmentBO> collection) {
		return documentAttachmentDao.saveAllDocumentAttachment(DocumentAttachmentConverter.toPO(collection));
	}

	@Override
	public int updateDocumentAttachment(DocumentAttachmentBO documentAttachmentBO) {
		return documentAttachmentDao.updateDocumentAttachment(DocumentAttachmentConverter.toPO(documentAttachmentBO));
	}

	@Override
	public int deleteDocumentAttachment(Long documentAttachmentId) {
		DocumentAttachmentBO documentAttachmentBO = new DocumentAttachmentBO();
		documentAttachmentBO.setUpdateTime(LocalDateTime.now()); //更新修改时间
		documentAttachmentBO.setDocumentAttachmentId(documentAttachmentId);
		return documentAttachmentDao.deleteDocumentAttachment(DocumentAttachmentConverter.toPO(documentAttachmentBO));
	}

	@Override
	public DocumentAttachmentBO getDocumentAttachment(Long documentAttachmentId) {
		return DocumentAttachmentConverter.fromPO(documentAttachmentDao.getDocumentAttachment(documentAttachmentId));
	}

	@Override
	public List<DocumentAttachmentBO> listDocumentAttachmentById(Collection<Long> collection) {
		return DocumentAttachmentConverter.fromPO(documentAttachmentDao.listDocumentAttachmentById(collection));
	}

	@Override
	public List<DocumentAttachmentBO> listDocumentAttachment(DocumentAttachmentQuery query) {
		return DocumentAttachmentConverter.fromPO(documentAttachmentDao.listDocumentAttachment(query));
	}

	@Override
	public int countDocumentAttachment(DocumentAttachmentQuery query) {
		return documentAttachmentDao.countDocumentAttachment(query);
	}

}
